#!/bin/bash
currentDir=$(cd $(dirname "${BASH_SOURCE[0]}") ; pwd)

cd ${currentDir}
tar -xzvf ${currentDir}/kernel-el7-x86.tar.gz >/dev/null 2>&1
rpm -ivh kernel-el7-x86/*.rpm
if [[ $? -eq 0 ]];then
	  echo 'success update kernel to 4.19.90'
	  echo '==================you need to reboot system!!!================='
	  rm ${currentDir}/kernel-el7-x86 -rf
else
	  echo "failed update kernel to 4.19.237"
	  rm ${currentDir}/kernel-el7-x86 -rf
	  exit 1
fi

sed -i 's/quiet/& mgag200.modeset=0/' /etc/default/grub
grub2-set-default "CentOS Linux (4.19.237-1.x86_64) 7 (Core)"

if [[ -f  /boot/efi/EFI/centos/grub.cfg ]];then
grub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg
elif [[ -f /boot/grub2/grub.cfg ]];then
grub2-mkconfig -o /boot/grub2/grub.cfg
else
	  echo "failed grub2-mkconfig"
      exit 1
fi